<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>seqtime2</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="serialWrite.html" title="serialWrite" />
    <link rel="next" href="seqtime.html" title="seqtime" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">seqtime2</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="serialWrite.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="seqtime.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="seqtime2"></a>
      <div class="titlepage"></div>
      <a id="IndexSeqtime2" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">seqtime2</span>
        </h2>
        <p>seqtime2 — 
      Generates a trigger signal according to the values stored in a table.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp145361088"></a>
        <h2>Description</h2>
        <p>
      Generates a trigger signal according to the values stored in a table.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp145362272"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ktrig_out <span class="command"><strong>seqtime2</strong></span> ktrig_in, ktime_unit, kstart, kloop, kinitndx, kfn_times</pre>
      </div>
      <div class="refsect1">
        <a id="idp145432608"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>ktrig_out</em></span> -- output trigger signal
    </p>
        <p>
      <span class="emphasis"><em>ktime_unit</em></span> -- unit of measure of time, related to seconds.
    </p>
        <p>
      <span class="emphasis"><em>ktrig_in</em></span> -- input trigger signal.
    </p>
        <p>
      <span class="emphasis"><em>kstart</em></span> -- start index of looped section
    </p>
        <p>
      <span class="emphasis"><em>kloop</em></span> -- end index of looped section
    </p>
        <p>
      <span class="emphasis"><em>kinitndx</em></span> -- initial index
    </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note: Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        Although <span class="emphasis"><em>kinitndx</em></span> is listed as k-rate, it is in fact accessed only at init-time. So if you are using a k-rate argument, it must be assigned with <a class="link" href="init.html" title="init"><em class="citetitle">init</em></a>.
      </p>
              </td>
            </tr>
          </table>
        </div>
        <p>
      <span class="emphasis"><em>kfn_times</em></span> -- number of table containing a sequence of times
    </p>
        <p>
      This opcode handles timed-sequences of groups of values stored into a table.
    </p>
        <p>
      <span class="emphasis"><em>seqtime2</em></span> generates a trigger signal (a
    sequence of impulses, see also <a class="link" href="trigger.html" title="trigger"><em class="citetitle">trigger</em></a> opcode),
    according to the values stored in the
    <span class="emphasis"><em>kfn_times</em></span> table. This table should contain a
    series of delta-times (i.e. times beetween to adjacent
    events). The time units stored into table are expressed in
    seconds, but can be rescaled by means of <span class="emphasis"><em>ktime_unit</em></span> argument. The
    table can be filled with <a class="link" href="GEN02.html" title="GEN02"><em class="citetitle">GEN02</em></a> or by means of
    an external text-file containing numbers, with <a class="link" href="GEN23.html" title="GEN23"><em class="citetitle">GEN23</em></a>.  
    </p>
        <p>
      It is possible to start the sequence from a value different than
    the first, by assigning to <span class="emphasis"><em>initndx</em></span> an index
    different than zero (which corresponds to the first value of the
    table). Normally the sequence is looped, and the start and end of
    loop can be adjusted by modifying <span class="emphasis"><em>kstart</em></span> and
    <span class="emphasis"><em>kloop</em></span> arguments. User must be sure that
    values of these arguments (as well as
    <span class="emphasis"><em>initndx</em></span>) correspond to valid table numbers,
    otherwise Csound will crash (because no range-checking is
    implementeted).  
    </p>
        <p>
      It is possible to disable loop (one-shot mode) by assigning the
    same value both to <span class="emphasis"><em>kstart</em></span> and
    <span class="emphasis"><em>kloop</em></span> arguments. In this case, the last read
    element will be the one corresponding to the value of such
    arguments.  Table can be read backward by assigning a negative
    <span class="emphasis"><em>kloop</em></span> value. It is possible to trigger two
    events almost at the same time (actually separated by a k-cycle)
    by giving a zero value to the corresponding delta-time.  First
    element contained in the table should be zero, if the user intends
    to send a trigger impulse, it should come immediately after the
    orchestra instrument containing <span class="emphasis"><em>seqtime2</em></span>
    opcode. 
    </p>
        <p>
      <span class="emphasis"><em>seqtime2</em></span> is similar to
      <a class="link" href="seqtime.html" title="seqtime"><em class="citetitle">seqtime</em></a>,
      the difference is that when
      <span class="emphasis"><em>ktrig_in</em></span> contains a non-zero value, current index is reset to
      <span class="emphasis"><em>kinitndx</em></span> value.  <span class="emphasis"><em>kinitndx</em></span> can be varied at performance time.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp145456032"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the seqtime2 opcode. It uses the file <a class="ulink" href="examples/seqtime2.csd" target="_top"><em class="citetitle">seqtime2.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp145457888"></a>
          <p class="title">
            <strong>Example 799. Example of the seqtime2 opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac    <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o seqtime2.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

gitabMap2 <span class="ohdr">ftgen</span>	57,0,512,<span class="op">-</span>2, 1,1<span class="op">/</span>4,1<span class="op">/</span>4,1<span class="op">/</span>8,1<span class="op">/</span>8,1<span class="op">/</span>8,1<span class="op">/</span>8,1<span class="op">/</span>4,1<span class="op">/</span>4,.5,1<span class="op">/</span>4,1<span class="op">/</span>4,1<span class="op">/</span>16,1<span class="op">/</span>16,1<span class="op">/</span>16,1<span class="op">/</span>16,1<span class="op">/</span>16,1<span class="op">/</span>16,1<span class="op">/</span>16,1<span class="op">/</span>16
gisine	  <span class="ohdr">ftgen</span>	1,0,512,10, 1

<span class="oblock">instr</span> 1

ktrigin	<span class="opc">metro</span>	.333333333333
ktrig2	<span class="opc">metro</span>	1
	<span class="opc">schedkwhen</span> ktrig2, 0,0, 2, 0, .1			<span class="comment">; just to set the metronome!</span>
kspeed	<span class="opc">init</span>	1
<span class="comment">;          	 ktime_unit, kstart, kloop, initndx, kfn_times </span>
ktrig	<span class="opc">seqtime2</span> ktrigin, kspeed, 0, 20, 2, gitabMap2
<span class="comment">;ktrig	seqtime	 kspeed, 0, 20, 0, gitabMap2			; try with seqtime too...		</span>
	<span class="opc">schedkwhen</span> ktrig, 0, 0, 3, 0, ktrig			<span class="comment">; the duration is got from seqtime2 output!</span>
<span class="oblock">endin</span>

<span class="oblock">instr</span> 2

a1	<span class="opc">line</span>	1,p3,0
aout	<span class="opc">oscili</span>	0.7<span class="op">*</span>a1,500,gisine
	<span class="opc">outs1</span>	aout
<span class="oblock">endin</span>	


<span class="oblock">instr</span> 3

a1	<span class="opc">line</span> 	1,p3,0
aout	<span class="opc">oscili</span>	0.7<span class="op">*</span>a1,1000,gisine
	<span class="opc">outs2</span>	aout
<span class="oblock">endin</span>	

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">i</span>1 0 20

<span class="comment">;f0 3600</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp145469344"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="GEN02.html" title="GEN02"><em class="citetitle">GEN02</em></a>,
      <a class="link" href="GEN23.html" title="GEN23"><em class="citetitle">GEN23</em></a>,
      <a class="link" href="seqtime.html" title="seqtime"><em class="citetitle">seqtime</em></a>,
      <a class="link" href="trigseq.html" title="trigseq"><em class="citetitle">trigseq</em></a>,
      <a class="link" href="trigseq.html" title="trigseq"><em class="citetitle">timedseq</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp145475216"></a>
        <h2>Credits</h2>
        <p>Author: Gabriel Maldonado</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="serialWrite.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="seqtime.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">serialWrite </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> seqtime</td>
        </tr>
      </table>
    </div>
  </body>
</html>
